﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using W.Purchase.API.Application.Command.SaleCommand;
using W.Purchase.Domain.DTO;
namespace W.Purchase.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class SaleController : ControllerBase
    {
        private readonly IMediator mediator;

        public SaleController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 销售删除
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> SaleOrderDelete(SaleOrderDeleteCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 销售批量删除
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> SaleOrderIsdelAll(SaleOrderIsdelAllCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 销售反填
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<List<SalesDTO>> SaleOrderFan(SaleOrderFanCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 销售添加
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> SaleOrderAdd(SaleOrderAddCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 销售撤编
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> SaleOrderUpdate(SaleOrderUpdateCommand command)
        {
            return await mediator.Send(command);
        }
    }
}
